/**
* @Author: 858834013@qq.com
* @Name: typeSelector
* @Date: 2022-01-18
* @Desc: 类型选择器
*/
<template>
	<div>
		<div @click="getshow">
			<slot></slot>
		</div>
		<u-picker :title="title" :show="show" @cancel="show=false" @confirm="getConfirm" :columns="list"></u-picker>
	</div>
</template>

<script>
	import {
		industryGetList
	} from '@/config/api.js'
	export default {
		name: 'typeSelector',
		components: {},
		props: {
			title: {
				type: String,
				default () {
					return ''
				}
			},
			type: {
				type: Boolean,
				default () {
					return false
				}
			},
		},
		data() {
			return {
				show: false,
				datalist: [],
				list: [
					[]
				]
			};
		},
		mounted() {
			this.getdata()
		},
		methods: {
			getshow() {
				this.show = true
			},
			getConfirm(e) {
				var that = this;
				console.log(e)
				console.log(that.datalist[e.indexs[0]])
				this.$emit('getdata', that.datalist[e.indexs[0]])
				this.show = false
			},
			getdata() {
				var that = this;
				that.list[0] = [];
				that.datalist = []
				industryGetList({}).then(res => {
					if (res.code == 200) {
						that.datalist = res.data.list
						if (that.type) {
							that.datalist.splice(0, 0, {
								id: '',
								name: '全部'
							});
						}
						that.datalist.forEach((type) => {
							that.list[0].push(type.name)
						});
					}
				}).catch(err => {

				})
			}
		}
	}
</script>

<style lang="scss" scoped>

</style>
